package controller.listeners.manualCode;



import model.ManualCodeModel;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

import business.database.filtersemantic.CorpsFilterEnum;

import view.ManualCodeView;

/**
 * Controlador para el boton que avanza la paginacion de corps a codificar
 * @author 53385255R
 *
 */
public class NextSelectionListener extends SelectionAdapter {

	private ManualCodeModel _model;
	private ManualCodeView _view;
	
	/**
	 * Constructor
	 * @param view
	 * @param model
	 */
	public NextSelectionListener(ManualCodeView view, ManualCodeModel model) {
		this._model = model;
		this._view = view;
	}
	
	/**
	 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
	 */
	@Override
	public void widgetSelected(SelectionEvent event) {

		int minid = _model.getMinIdCodeCorp();
	 	int maxid = _model.getMaxIdCodeCorp();
		//Limpio centros, corps, etc
	 	 _model.reset();
	 	
	 	 _view.resetFilter();//setCorpFilter("");
	 	CorpsFilterEnum filterEnum = _view.getFilterCombo();
	 	 _model.setCorpFilter("true","","","","","","","","","","",filterEnum,minid,maxid);
	 	 
	 	 _model.set_custom_corp("");
	 	
	 	 _view.setCachePreCodeCorps(_model.get_cache_precodecorps());
	 	 _view.setCandidateCenters(_model.getCandidateCenters(),_view.getSelected_cache_code_corp());
		
	}
}
